package com.ltkj.system.api.factory;

import com.ltkj.common.core.domain.R;
import com.ltkj.system.api.RemoteGameDataService;
import com.ltkj.system.api.domain.GameDataVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteGameDataFallbackFactory implements FallbackFactory<RemoteGameDataService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteGameDataFallbackFactory.class);

    @Override
    public RemoteGameDataService create(Throwable throwable)
    {
        log.error("赛事服务调用失败:{}", throwable.getMessage());
        return new RemoteGameDataService()
        {

            @Override
            public R<GameDataVo> getGameInfo(Long id, String source) {
                return R.fail("获取赛事信息失败:" + throwable.getMessage());
            }

            @Override
            public R delGameMember(Long gameId, Long userId, String source) {
                return R.fail("删除赛事成员失败:" + throwable.getMessage());
            }
        };
    }
}
